<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var total=prompt('输入猴子的整数');
        var kick=prompt('踢出第几只猴子');
        var monkey=[];
        for(var i=1;i<=total;i++){
            monkey.push(i)
        }
        i=0
        while(monkey.length>1){
            ++i;
            head=monkey.shift();
            if(i%kick!=0){
                monkey.push(head);
            }
        }
        console.log('猴王编号:'+monkey[0]);
    </script>
</body>
</html>